package com.vca.front.controller;


import com.vca.common.model.course.Course;
import com.vca.common.request.CourseFilterRequest;
import com.vca.common.result.CommonResult;
import com.vca.common.vo.CourseListVo;
import com.vca.common.vo.CourseVo;
import com.vca.service.service.CourseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 课程表 前端控制器
 * </p>
 *
 * @author chenBing
 * @since 2022-09-19
 */
@Slf4j
@RestController("CourseController")
@RequestMapping("api/front/vcaCourse")
@Api(tags = "课程控制器")
public class CourseController {

    @Autowired
    private CourseService courseService;

    /**
     * @Description:列表
     * @Author: chenBing
     * @Date: 2022/11/25
     */
    @ApiOperation(value = "课程列表")
    @GetMapping(value = "/list")
    public CommonResult<List<CourseListVo>> listNoPage(
            @RequestHeader(value = "language",required = false) String language,
            @Validated CourseFilterRequest request
    ) {
        request.setIsSelect(false);
        return CommonResult.success(courseService.getListNoPage(language,request));
    }
    @ApiOperation(value = "课程列表不带排期")
    @GetMapping(value = "/listNoScheduling")
    public CommonResult<List<CourseVo>> listNoScheduling(@RequestHeader(value="language",required = false) String language,@Validated CourseFilterRequest request){
        return CommonResult.success(courseService.listNoScheduling(language,request));
    }

    /**
     * @Description:课程详情列表
     * @Author: chenBing
     * @Date: 2022/9/23
     */
    @ApiOperation(value = "课程详情")
    @RequestMapping(value = "/info", method = RequestMethod.GET)
    public CommonResult<CourseVo> info(
            @RequestHeader(value = "language",required = false) String language,
            @RequestParam(value = "courseId") Long courseId
    ) {
        return CommonResult.success(courseService.info(language,courseId));
    }

    /**
     * @Description:套课详情
     * @Author: chenBing
     * @Date: 2022/11/21
     */
    @ApiOperation(value = "套课详情")
    @RequestMapping(value = "/package/info", method = RequestMethod.GET)
    public CommonResult<CourseVo> packageInfo(
            @RequestHeader(value = "language",required = false) String language,
            @RequestParam(value = "coursePackageId") Long coursePackageId
    ) {
        return CommonResult.success(courseService.packageInfo(language,coursePackageId));
    }
}

